#include "videoimage.h"
#include <QDebug>

VideoImage::VideoImage(): ImageBase()
{

}


int VideoImage::getCvMat(Mat &cvMat)
{
    capture.read(cvMat);
    if(cvMat.empty() || !cvMat.data)
        return -1;
    else
        return 0;
}

int VideoImage::setSource(QString path)
{
    QFileInfo fileinfo(path);
    if(fileinfo.isFile()){
        sourceFile = path;
        capture.open(path.toStdString());
        if(!capture.isOpened()){
            qDebug() << "[info] can not open video file";
            return -1;
        }

    }
    return 0;
}

QString VideoImage::getSource()
{
    return sourceFile;
}
